<template>
  <card title="知识库">
    <template v-slot:headerOpt>
      <div class="more-btn" @click="showMore">更多<i class="el-icon-d-arrow-right" /></div>
    </template>
    <div class="to-do-list">
      <div v-for="(item,m) in documentlist" :key="'todolist_'+m" class="to-do-item" @click="viewDetail(item)">
        <span class="content">【{{ item.keyword }}】{{ item.name }}</span>
        <span class="time">{{ item.createTime | date }}</span>
      </div>
    </div>
    <!-- 知识库详情 -->
    <add-file opt-type="detail" :data="docDetail" :show-modal.sync="showDocModal" />
  </card>
</template>

<script>
import { getDocumentDetailList } from '@/api/knowledgeBase'
import addFile from '../../../repository/components/addFile.vue'

import card from '../card.vue'
export default {
  name: 'Docs',
  components: {
    card,
    addFile
  },
  data() {
    return {
      documentlist: [],
      docDetail: {},
      showDocModal: false
    }
  },
  mounted() {
    this.getDocumentList()
  },
  methods: {
    getDocumentList() {
      getDocumentDetailList({ pageNum: 1, pageSize: 10 }).then(res => {
        if (res && res.code === '0001') {
          this.documentlist = res.data.data
        }
      })
    },
    showMore() {
      this.$emit('showMore', '2')
    },
    viewDetail(data) {
      this.docDetail = data
      this.showDocModal = true
    }
  }
}
</script>

<style lang="scss" scoped>

</style>
